const koa = require('koa');
const app = koa();

app.use(function *() {
    this.body = 'Hello World!';
    if (this.req.url === '/err') {
        this.throw('throw err', 503);
    }
    this.assert(this.user, 401, 'User not found. Please login!');
});

app.on('error', function (err, ctx) {
    console.warn('server error: ');
    console.error(err);
    console.log(ctx);

});

app.listen(3000);

// 访问 localhost:3000/err